package com.gljr.exam.dao;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.transaction.annotation.Transactional;

import com.gljr.exam.domain.ExamPaperQuestion;

public interface ExamPaperQuestionRepository extends PagingAndSortingRepository<ExamPaperQuestion, Long> {

	ExamPaperQuestion findExquestionByExnum(Long exnum);

	ExamPaperQuestion findExoptaByExnum(Long exnum);

	ExamPaperQuestion findExoptbByExnum(Long exnum);

	ExamPaperQuestion findExoptcByExnum(Long exnum);

	ExamPaperQuestion findExoptdByExnum(Long exnum);

	ExamPaperQuestion findExkeyById(Long i);

	ExamPaperQuestion findExkeyByExnum(Long exnum);

	ExamPaperQuestion findByExquestion(String exquestion);

	ExamPaperQuestion findExoptaById(Long num1);

	ExamPaperQuestion findExoptbById(Long num1);

	ExamPaperQuestion findExoptcById(Long num1);

	ExamPaperQuestion findExoptdById(Long num1);

	ExamPaperQuestion findExnumById(Long num1);

	@Query("select exquestion from ExamPaperQuestion  where exnum = ?1")
	String findExquestionByExnum2(Long exnum);

	@Query("select exkey from ExamPaperQuestion  where exnum = ?1")
	String findExkeyByExnum2(Long exnum);// 通过题号找寻答案

	@Query("select max(id) FROM ExamPaperQuestion")
	Long findMaxID();

	@Query("select max(id) FROM ExamPaperQuestion")
	int findMaxIDInt();

	@Modifying
	@Transactional
	@Query("UPDATE ExamPaperQuestion SET exquestion = ?2 WHERE exnum = ?1") // 根据题号修改问题
	void updateAllTopic(Long exnum, String exquestion);

}
